<md-card>
    <table ng-if="settings" class="table">
        <tr>
            <th>Failover Limit</th>
        </tr>
        <tr>
            <td>
                <md-slider ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-value="selectedCluster.config.failoverLimit" md-discrete flex
                           ng-model="selectedFailoverLimit" ng-change="changefailoverlimit(selectedFailoverLimit)" step="1" min="0" max="10" aria-label="failover limit">
                </md-slider>
                <span class="label label-primary">{{selectedCluster.config.failoverLimit}}</span>
            </td>
        </tr>
        <tr>
            <th>Checks failover & switchover constraints</th>
        </tr>
        <tr>
            <td>
                <md-switch ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false" ng-model="selectedCluster.config.checkReplicationState"
                           ng-click="switchsettings('check-replication-state')"
                           aria-label="Failover in Sync">
                    <span ng-if="selectedCluster.config.checkReplicationState"
                          ng-click="switchsettings('check-replication-state')" class="label label-primary">On</span><span
                        ng-if="!selectedCluster.config.checkReplicationState" ng-click="rplchecks()"
                        class="label label-warning">Off</span>
                </md-switch>
            </td>
        </tr>
      </table>
      </md-card>
      <BR>
      <md-card>
      <table ng-if="settings" class="table">
        <tr>
            <th>Failover only on semi-sync state is in sync</th>
        </tr>
        <tr>
            <td>
                <md-switch ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false" ng-model="selectedCluster.config.failoverAtSync"
                           ng-click="switchsettings('failover-at-sync')" aria-label="Failover in Sync">
                    <span ng-if="selectedCluster.config.failoverAtSync" ng-click="switchsettings('failover-at-sync')"
                          class="label label-primary">On</span>
                    <span ng-if="!selectedCluster.config.failoverAtSync"
                                                                     ng-click="failsync()"
                                                                     class="label label-warning">Off</span>
                </md-switch>
            </td>
        </tr>
        <tr>
            <th>Failover unsafe fisrt slave</th>
        </tr>
        <tr>
            <td>
                <md-switch ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false" ng-model="selectedCluster.config.failoverRestartUnsafe"
                           ng-click="switchsettings('failover-restart-unsafe')" aria-label="Failover Restart Unsafe">
                    <span ng-if="selectedCluster.config.failoverRestartUnsafe"  class="label label-primary">On</span>
                    <span ng-if="!selectedCluster.config.failoverRestartUnsafe"  class="label label-warning">Off</span>
                </md-switch>
            </td>
        </tr>
        <tr>
            <th>Failover using positional replication</th>
        </tr>
        <tr>
            <td>
                <md-switch  ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false"
                           ng-model="selectedCluster.config.forceSlaveNoGtidMode"
                           ng-click="switchsettings('force-slave-no-gtid-mode')"
                           aria-label="Failover using positional replication">
                    <span ng-if="selectedCluster.config.forceSlaveNoGtidMode"
                          class="label label-primary">On</span><span
                        ng-if="!selectedCluster.config.forceSlaveNoGtidMode" class="label label-warning">Off</span>

            </md-switch>
            </td>
        </tr>
        <tr>
            <th>Failover using pseudo GTID</th>
        </tr>
        <tr>
            <td>
                <md-switch  ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false"
                           ng-model="selectedCluster.config.autorejoinSlavePositionalHeartbeat"
                           ng-click="switchsettings('autorejoin-slave-positional-heartbeat')"
                           aria-label="Auto rejoin using pseudo GTID">
                    <span ng-if="selectedCluster.config.autorejoinSlavePositionalHeartbeat"
                          class="label label-primary">On</span><span
                        ng-if="!selectedCluster.config.autorejoinSlavePositionalHeartbeat" class="label label-warning">Off</span>

            </md-switch>
            </td>
        </tr>
        <tr>
            <th>Capture statistic for hourly delay average</th>
        </tr>
        <tr>
            <td>
                <md-switch  ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false"
                           ng-model="selectedCluster.config.delayStatCapture"
                           ng-click="switchsettings('delay-stat-capture')"
                           aria-label="capture delay statistics">
                    <span ng-if="selectedCluster.config.delayStatCapture"
                          class="label label-primary">On</span><span
                        ng-if="!selectedCluster.config.delayStatCapture" class="label label-warning">Off</span>

            </md-switch>
            </td>
        </tr>
        <tr>
            <th>Failover check delay statistics</th>
        </tr>
        <tr>
            <td>
                <md-switch  ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false || !selectedCluster.config.delayStatCapture" ng-true-value="true" ng-false-value="false"
                           ng-model="selectedCluster.config.failoverCheckDelayStat"
                           ng-click="switchsettings('failover-check-delay-stat')"
                           aria-label="Failover check delay statistics">
                    <span ng-if="selectedCluster.config.failoverCheckDelayStat"
                          class="label label-primary">On</span><span
                        ng-if="!selectedCluster.config.failoverCheckDelayStat" class="label label-warning">Off</span>

            </md-switch>
            </td>
        </tr>
        <tr>
            <th>Delay Statistic Rotate Hours</th>
        </tr>
        <tr>
            <td>
                <md-slider ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-value="selectedCluster.config.delayStatRotate" md-discrete flex
                           ng-model="selectedDelayStatRotate" ng-change="changedelaystatrotate(selectedDelayStatRotate)" step="1" min="0" max="72" aria-label="<!-- WARNING:  -->ait">
                </md-slider>
    
                <span class="label label-primary">{{selectedCluster.config.delayStatRotate}}</span>
    
            </td>
        </tr>
        <tr>
            <th>Print delay statistic</th>
        </tr>
        <tr>
            <td>
                <md-switch  ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false || !selectedCluster.config.delayStatCapture" ng-true-value="true" ng-false-value="false"
                           ng-model="selectedCluster.config.printDelayStat"
                           ng-click="switchsettings('print-delay-stat')"
                           aria-label="print delay statistics">
                    <span ng-if="selectedCluster.config.printDelayStat"
                          class="label label-primary">On</span><span
                        ng-if="!selectedCluster.config.printDelayStat" class="label label-warning">Off</span>

            </md-switch>
            </td>
        </tr>
        <tr>
            <th>Print delay statistic history</th>
        </tr>
        <tr>
            <td>
                <md-switch  ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false || !selectedCluster.config.delayStatCapture" ng-true-value="true" ng-false-value="false"
                           ng-model="selectedCluster.config.printDelayStatHistory"
                           ng-click="switchsettings('print-delay-stat-history')"
                           aria-label="print delay statistics history">
                    <span ng-if="selectedCluster.config.printDelayStatHistory"
                          class="label label-primary">On</span><span
                        ng-if="!selectedCluster.config.printDelayStatHistory" class="label label-warning">Off</span>

            </md-switch>
            </td>
        </tr>
        <tr>
            <th>Delay Statistic Print Interval</th>
        </tr>
        <tr>
            <td>
                <md-slider ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-value="selectedCluster.config.printDelayStatInterval" md-discrete flex
                           ng-model="selectedPrintDelayStatInterval" ng-change="changeprintdelaystatinterval(selectedPrintDelayStatInterval)" step="1" min="0" max="60" aria-label="<!-- WARNING:  -->ait">
                </md-slider>
    
                <span class="label label-primary">{{selectedCluster.config.printDelayStatInterval}}</span>
    
            </td>
        </tr>
        </table>
      </md-card>
      <BR>
      <md-card>

        <table ng-if="settings" class="table">
        <tr>
            <th>Switchover only on semi-sync state in sync</th>
        </tr>
        <tr>
            <td>
                <md-switch ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false" ng-model="selectedCluster.config.switchoverAtSync"
                           ng-click="switchsettings('switchover-at-sync')()"
                           aria-label="Switchover in Sync">
                    <span ng-if="selectedCluster.config.switchoverAtSync"
                          ng-click="switchsettings('switchover-at-sync')"
                          class="label label-primary">On</span><span ng-if="!selectedCluster.config.switchoverAtSync"
                                                                     ng-click="switchsync()"
                                                                     class="label label-warning">Off</span>
                </md-switch>
            </td>
        </tr>
        <tr>
            <th>Switchover replication maximum delay</th>
        </tr>
        <tr>
            <td>
                <md-slider ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-value="selectedCluster.config.failoverMaxSlaveDelay" md-discrete ng-if="selectedCluster.config.checkReplicationState" flex
                           ng-model="selectedMaxSlaveDelay" ng-change="changemaxdelay(selectedMaxSlaveDelay)" step="1" min="10" max="100" aria-label="delay">
                </md-slider>

                <span class="label label-primary">{{selectedCluster.config.failoverMaxSlaveDelay}}</span>

            </td>
        </tr>
        <tr>
            <th>Switchover wait unmanaged proxy monitor detection</th>
        </tr>
        <tr>
            <td>
                <md-slider ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-value="selectedCluster.config.switchoverWaitRouteChange" md-discrete flex
                           ng-model="selectedSwitchoverWaitRouteChange" ng-change="changeswitchoverwaitroutechange(selectedSwitchoverWaitRouteChange)" step="1" min="0" max="10" aria-label="<!-- WARNING:  -->ait">
                </md-slider>

                <span class="label label-primary">{{selectedCluster.config.switchoverWaitRouteChange}}</span>

            </td>
        </tr>
        <tr>
            <th>Switchover allow on minor release</th>
        </tr>
        <tr>
            <td>
              <md-switch ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false" ng-model="selectedCluster.config.switchoverLowerRelease"
                         ng-click="switchsettings('switchover-lower-release')"
                         aria-label="Enforce read only on replicas">
                         <span ng-if="selectedCluster.config.switchoverLowerRelease" class="label label-primary">On</span>
                         <span ng-if="!selectedCluster.config.switchoverLowerRelease" class="label label-warning">Off</span>
              </md-switch>

            </td>
        </tr>
    </table>
  </md-card>
  <BR>
  <md-card>

      <table ng-if="settings" class="table">
          <tr>
              <th>Enforce replication options</th>
          </tr>
          <tr>
              <td>
                  Enforce read only on replicas
                  <md-switch ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false" ng-model="selectedCluster.config.forceSlaveReadonly"
                             ng-click="switchsettings('force-slave-readonly')"
                             aria-label="Enforce read only on replicas">
                             <span ng-if="selectedCluster.config.forceSlaveReadonly" class="label label-primary">On</span>
                             <span ng-if="!selectedCluster.config.forceSlaveReadonly" class="label label-warning">Off</span>
                  </md-switch>
              </td>
          </tr>
          <tr>
              <td>
                  Enforce binlog format in row
                  <md-switch ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false" ng-model="selectedCluster.config.forceBinlogRow"
                             ng-click="switchsettings('force-binlog-row')"
                             aria-label="Enforce binlog format in row">
                             <span ng-if="selectedCluster.config.forceBinlogRow" class="label label-primary">On</span>
                             <span ng-if="!selectedCluster.config.forceBinlogRow" class="label label-warning">Off</span>
                  </md-switch>
              </td>
          </tr>
          <tr>
              <td>
                  Enforce binlog row log with original statement
                  <md-switch ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false" ng-model="selectedCluster.config.forceBinlogAnnotate"
                             ng-click="switchsettings('force-binlog-annotate')"
                             aria-label="Enforce binlog row with original statement">
                             <span ng-if="selectedCluster.config.forceBinlogAnnotate" class="label label-primary">On</span>
                             <span ng-if="!selectedCluster.config.forceBinlogAnnotate" class="label label-warning">Off</span>
                  </md-switch>
              </td>
          </tr>
          <tr>
              <td>
                  Enforce binlog compression
                  <md-switch ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false" ng-model="selectedCluster.config.forceBinlogCompress"
                             ng-click="switchsettings('force-binlog-compress')"
                             aria-label="Enforce binlog compression">
                             <span ng-if="selectedCluster.config.forceBinlogCompress" class="label label-primary">On</span>
                             <span ng-if="!selectedCluster.config.forceBinlogCompress" class="label label-warning">Off</span>
                  </md-switch>
              </td>
          </tr>
          <tr>
              <td>
                  Enforce replication queries in slow queries log
                  <md-switch ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false" ng-model="selectedCluster.config.forceBinlogSlowqueries"
                             ng-click="switchsettings('force-binlog-compress')"
                             aria-label="Enforce replication queries in slow queries">
                             <span ng-if="selectedCluster.config.forceBinlogSlowqueries" class="label label-primary">On</span>
                             <span ng-if="!selectedCluster.config.forceBinlogSlowqueries" class="label label-warning">Off</span>
                  </md-switch>
              </td>
          </tr>
          <tr>
              <td>
                  Enforce GTID replication
                  <md-switch ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false" ng-model="selectedCluster.config.forceSlaveGtidMode"
                             ng-click="switchsettings('force-slave-gtid')"
                             aria-label="Enforce GTID replication ">
                             <span ng-if="selectedCluster.config.forceSlaveGtidMode" class="label label-primary">On</span>
                             <span ng-if="!selectedCluster.config.forceSlaveGtidMode" class="label label-warning">Off</span>
                  </md-switch>
              </td>
          </tr>
          <tr>
              <td>
                  Enforce replication stop when write on replicas
                  <md-switch ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false" ng-model="selectedCluster.config.forceSlaveGtidModeStrict"
                             ng-click="switchsettings('force-slave-gtid-mode-strict')"
                             aria-label="Enforce replication stop when write on replicas">
                             <span ng-if="selectedCluster.config.forceSlaveGtidModeStrict" class="label label-primary">On</span>
                             <span ng-if="!selectedCluster.config.forceSlaveGtidModeStrict" class="label label-warning">Off</span>
                  </md-switch>
              </td>
          </tr>
          <tr>
              <td>
                  Enforce replication semi-synchronus
                  <md-switch ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false" ng-model="selectedCluster.config.forceSlaveSemisync"
                             ng-click="switchsettings('force-slave-semisync')"
                             aria-label="Enforce replication semi-synchronus ">
                             <span ng-if="selectedCluster.config.forceSlaveSemisync" class="label label-primary">On</span>
                             <span ng-if="!selectedCluster.config.forceSlaveSemisync" class="label label-warning">Off</span>
                  </md-switch>
              </td>
          </tr>
          <tr>
              <td>
                  Enforce replication mode strict, sql thread error when dataset diverge
                  <md-switch ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false" ng-model="selectedCluster.config.forceSlaveStrict"
                             ng-click="switchsettings('force-slave-strict')"
                             aria-label="Enforce replication mode strict ">
                             <span ng-if="selectedCluster.config.forceSlaveStrict" class="label label-primary">On</span>
                             <span ng-if="!selectedCluster.config.forceSlaveStrict" class="label label-warning">Off</span>
                  </md-switch>
              </td>
          </tr>
          <tr>
              <td>
                  Enforce replication mode idempotent, sql thread repair based on binlog row image when dataset diverge
                  <md-switch ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false" ng-model="selectedCluster.config.forceSlaveIdempotent"
                             ng-click="switchsettings('force-slave-idempotent')"
                             aria-label="Enforce replication idempotent ">
                             <span ng-if="selectedCluster.config.forceSlaveIdempotent" class="label label-primary">On</span>
                             <span ng-if="!selectedCluster.config.forceSlaveIdempotent" class="label label-warning">Off</span>
                  </md-switch>
              </td>
          </tr>
          <tr>
              <td>
                  Enforce replication parallel mode serialized
                  <md-switch ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false" ng-model="selectedCluster.config.forceSlaveParallelMode.toUpperCase()=='SERIALIZED'"
                             ng-click="switchsettings('force-slave-serialized')"
                             aria-label="Enforce replication serialized ">
                             <span ng-if="selectedCluster.config.forceSlaveParallelMode.toUpperCase()=='SERIALIZED'" class="label label-primary">On</span>
                             <span ng-if="!selectedCluster.config.forceSlaveParallelMode.toUpperCase()=='SERIALIZED'" class="label label-warning">Off</span>
                  </md-switch>
              </td>
          </tr>
          <tr>
              <td>
                  Enforce replication parallel mode minimal
                  <md-switch ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false" ng-model="selectedCluster.config.forceSlaveParallelMode.toUpperCase()=='MINIMAL'"
                             ng-click="switchsettings('force-slave-minimal')"
                             aria-label="Enforce replication minimal ">
                             <span ng-if="selectedCluster.config.forceSlaveParallelMode.toUpperCase()=='MINIMAL'" class="label label-primary">On</span>
                             <span ng-if="!selectedCluster.config.forceSlaveParallelMode.toUpperCase()=='MINIMAL'" class="label label-warning">Off</span>
                  </md-switch>
              </td>
          </tr>
          <tr>
              <td>
                  Enforce replication parallel mode conservative
                  <md-switch ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false" ng-model="selectedCluster.config.forceSlaveParallelMode.toUpperCase()=='CONSERVATIVE'"
                             ng-click="switchsettings('force-slave-conservative')"
                             aria-label="Enforce replication conservative ">
                             <span ng-if="selectedCluster.config.forceSlaveParallelMode.toUpperCase()=='CONSERVATIVE'" class="label label-primary">On</span>
                             <span ng-if="!selectedCluster.config.forceSlaveParallelMode.toUpperCase()=='CONSERVATIVE'" class="label label-warning">Off</span>
                  </md-switch>
              </td>
          </tr>
          <tr>
              <td>
                  Enforce replication parallel mode optimistic
                  <md-switch ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false" ng-model="selectedCluster.config.forceSlaveParallelMode.toUpperCase()=='OPTIMISTIC'"
                             ng-click="switchsettings('force-slave-optimistic')"
                             aria-label="Enforce replication optimistic ">
                             <span ng-if="selectedCluster.config.forceSlaveParallelMode.toUpperCase()=='OPTIMISTIC'" class="label label-primary">On</span>
                             <span ng-if="!selectedCluster.config.forceSlaveParallelMode.toUpperCase()=='OPTIMISTIC'" class="label label-warning">Off</span>
                  </md-switch>
              </td>
          </tr>
          <tr>
              <td>
                  Enforce replication parallel mode aggressive
                  <md-switch ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false" ng-model="selectedCluster.config.forceSlaveParallelMode.toUpperCase()=='AGGRESSIVE'"
                             ng-click="switchsettings('force-slave-aggressive')"
                             aria-label="Enforce replication agressive ">
                             <span ng-if="selectedCluster.config.forceSlaveParallelMode.toUpperCase()=='AGGRESSIVE'" class="label label-primary">On</span>
                             <span ng-if="!selectedCluster.config.forceSlaveParallelMode.toUpperCase()=='AGGRESSIVE'" class="label label-warning">Off</span>
                  </md-switch>
              </td>
          </tr>
          <tr>
              <td>
                  Enforce replication heartbeat avoid SQL thread disconnect when no writes during full TCP socket timelife
                  <md-switch ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false" ng-model="selectedCluster.config.forceSlaveHeartbeat"
                             ng-click="switchsettings('force-slave-heartbeat')"
                             aria-label="Enforce replication heartbeat needed if no writes during 8 hours">
                             <span ng-if="selectedCluster.config.forceSlaveHeartbeat" class="label label-primary">On</span>
                             <span ng-if="!selectedCluster.config.forceSlaveHeartbeat" class="label label-warning">Off</span>
                  </md-switch>
              </td>
          </tr>
          </table>

</md-card>
